﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>ccform正在加载请稍候...</title>
    <link href="../../Scripts/easyUI145/themes/color.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="../../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../Gener.js"></script>
    <script src="../JS/Calendar/WdatePicker.js" type="text/javascript"></script>
    <link href="../JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />

    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />


    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
    <script type="text/javascript" src="../../Scripts/Cookie.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.nav.js"></script>
    <script type="text/javascript" src="../../Scripts/QueryString.js"></script>
    <script src="../../Scripts/bootstrap/BootstrapUIDialog.js" type="text/javascript"></script>
    <link href="../../Scripts/bootstrap/css/bootstrap.css" rel="Stylesheet" />
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>

    <link href="../../Scripts/bootstrap/css/font-awesome.css" rel="Stylesheet" />
    <link rel="stylesheet" href="../../Scripts/bootstrap/css/css.css" type="text/css" media="all" />

    <!-- 该文件可以被集成厂商自己定义风格,可以自己修改,以达到流程设计器与自己的系统风格统一. -->
    <link href="../../../DataUser/Style/ccbpm.css" rel="Stylesheet" />

    <!--UEditor-->
    <link href="../../Comm/umeditor1.2.3-utf8/themes/default/css/umeditor.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../../Comm/umeditor1.2.3-utf8/third-party/template.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../Comm/umeditor1.2.3-utf8/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../Comm/umeditor1.2.3-utf8/umeditor.min.js"></script>
    <script type="text/javascript" src="../../Comm/umeditor1.2.3-utf8/lang/zh-cn/zh-cn.js"></script>
    <style type="text/css">
        th {
            border: 1px solid #ccc;
            background-color: #f5f5f5;
        }
    </style>
    <script type="text/javascript">

        var newRowIdx = -1;
        var frmData;
        var mapData;
        var mainData;
        var dtM; //方法集合.

        $(function () {

            var httpHandler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
            httpHandler.AddUrlData();  //增加参数属性.

            var data = httpHandler.DoMethodReturnString("Dtl_Init");
            if (data.indexOf('err@') == 0) {
                $("#Msg").html(data);
                return;
            }

            //解析json.
            frmData = JSON.parse(data);

            mapData = frmData["Sys_MapData"][0];
            mapData = new Entity("BP.Sys.MapData", mapData); //把他转化成entity.
            // mainData = frmData["MainData"];
            document.title = mapData.Name;
            var isReadonly = GetQueryString("IsReadonly");

            InitToolbar(); //初始工具栏.

            //绑定数据.
            BindDtls(mapData, mainData, frmData);

        })

        function OpenEn(pkVal) {
            var pEnName = GetQueryString("EnName");
            var ensName = GetQueryString("EnsName");
            var enName = ensName.substring(0, ensName.length - 1);
            if (pEnName == null && pEnName == undefined && pEnName == "") {

                var url = "En.htm?EnName=" + enName + "&PKVal=" + pkVal + "&RefVal=" + GetQueryString("RefVal") + "&RefKey=" + GetQueryString("RefKey");

                OpenBootStrapModal(url, "eudlgframe", this.document.title + ' : 详细', 650, 600, "icon-edit", false, function () { }, null, function () {

                    Reload();

                });
                return;
            }

            //否则按照Search.htm设置的方式打开详情页面
            var cfg = new Entity("BP.Sys.EnCfg");
            cfg.No = pEnName + "s";
            cfg.RetrieveFromDBSources();

            //当前URL参数
            var currUrl = window.location.search.substring(1);

            var url = cfg.UrlExt;
            var urlOpenType = cfg.GetPara("SearchUrlOpenType");

            if (urlOpenType == 0 || urlOpenType == undefined)
                url = "./En.htm?EnName=" + enName + "&PKVal=" + pkVal + "&RefVal=" + GetQueryString("RefVal") + "&RefKey=" + GetQueryString("RefKey");

            if (urlOpenType == 1)
                url = "./EnOnly.htm?EnName=" + enName + "&PKVal=" + pkVal + "&RefVal=" + GetQueryString("RefVal") + "&RefKey=" + GetQueryString("RefKey");


            var windowW = cfg.GetPara("WinCardW");
            if (windowW == "" || windowW == undefined)
                windowW = 900;

            var windowH = cfg.GetPara("WinCardH");
            if (windowH == "" || windowH == undefined)
                windowH = 500;

            OpenBootStrapModal(url, "eudlgframe", this.document.title + ' : 详细', windowW, windowH, "icon-edit", false, function () { }, null, function () {

                Reload();
                //window.location.href = window.location.href

            });





        }

        //设置按钮
        function InitToolbar() {

            var html = "";

            //权限控制.
            if (mapData.GetPara("IsInsert") == 1) {
                html += "<button  value='新建' id='Btn_New' onclick='New()' class='cc-btn-tab btn-new' >新建</button>";
            }

            if (mapData.GetPara("IsUpdate") == 1) {
                html += "<button type='button' value='保存' id='Btn_Save' onclick='Save()' class='cc-btn-tab btn-save' >保存</button>";
            }
            if (mapData.GetPara("IsImp") == 1) {
                html += "<button  type='button' value='导入' id='Btn_Imp' onclick='Import()' class='cc-btn-tab btn-imp' >导入</button>";
            }

            html += "<button type='button' value='导出' id='Btn_Exp' onclick='Export()' class='cc-btn-tab btn-exp' >导出</button>";


            $("#Btns").append(html);
        }

        //绑定明细.
        function BindDtls(mapData, mainData, frmData) {

            frmData = frmData;
            var Sys_GroupFields = frmData.Sys_GroupField;
            var mapAttrs = frmData.Sys_MapAttr;
            var dtls = frmData.Dtls;

            var html = "<table class='table' id='Table1'>";
            html += "<tr>";
            html += "<th>序</th>";


            for (var i = 0; i < mapAttrs.length; i++) {
                var mapAttr = mapAttrs[i];
                mapAttr = new Entity("BP.Sys.SysMapAttr", mapAttr);
                if (mapAttr.UIVisible == "0")
                    continue;
                html += "<th>" + mapAttr.Name + "</th>";
            }
            html += "<th>....</th>";
            html += "<th></th>";
            html += "</tr>";


            var hidden = "";

            //生成内容.
            for (var i = 0; i < dtls.length; i++) {

                var dtl = dtls[i];
                //dtl = new Entity("BP.Sys.GEDtl", dtl);
                var pkval = dtl.OID;
                if (pkval == undefined)
                    pkval = dtl.MyPK;
                if (pkval == undefined)
                    pkval = dtl.No;
                if (pkval == dtl.NodeID)
                    pkval = dtl.NodeID;
                if (pkval == dtl.WorkID)
                    pkval = dtl.WorkID;

                html += "<tr>"; // ondblclick='OpenEn(\"" + pkval + "\")'
                html += "<td class='Idx'>" + (i + 1) + "</td>";


                for (var attrIdx = 0; attrIdx < mapAttrs.length; attrIdx++) {
                    var mapAttr = mapAttrs[attrIdx];
                    mapAttr = new Entity("BP.Sys.SysMapAttr", mapAttr);
                    if (mapAttr.UIVisible == "0") {
                        html += "<input type='hidden' id='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' value='" + dtl[mapAttr.KeyOfEn] + "' />";
                        continue;
                    }

                    html += "<td>" + InitMapAttrOfCtrl(mapAttr, dtl, pkval) + "</td>";
                }
                //主键中还有双引号的进行转义
                if (pkval != null && pkval != undefined && pkval instanceof String)
                    pkval = pkval.replace(/"/g, "&quot;");
                html += "<td ><a href=\"javascript:OpenEn('" + pkval + "')\">详细</a></td>";
                if (mapData.GetPara("IsDelete") == "1")
                    html += "<td><a href=\"javascript:Delete('" + pkval + "')\"><img src='../../Img/Btn/Delete.png' /></a></td>";
                else
                    html += "<td></td>";



                html += "</tr>";
            }
            html += "</table>";


            var html = $(html);
            $('#mytable').html("").append(html);
            $('#mytable').append(hidden);

            for (var i = 0; i < dtls.length; i++) {

                var dtl = dtls[i];
                //dtl = new Entity("BP.Sys.GEDtl", dtl);
                var pkval = dtl.OID;
                if (pkval == undefined)
                    pkval = dtl.MyPK;
                if (pkval == undefined)
                    pkval = dtl.No;
                if (pkval == dtl.NodeID)
                    pkval = dtl.NodeID;
                if (pkval == dtl.WorkID)
                    pkval = dtl.WorkID;
                for (var attrIdx = 0; attrIdx < mapAttrs.length; attrIdx++) {
                    var mapAttr = mapAttrs[attrIdx];
                    if (mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContralType == "1") {
                        if ($("#TB_" + pkval + "_" + mapAttr.KeyOfEn + "Text").length == 1) {
                            if (defValue == "")
                                $("#TB_" + pkval + "_" + mapAttr.KeyOfEn + "Text").val($('#DDL_' + pkval + "_" + mapAttr.KeyOfEn + " option:first").text());
                            else
                                $("#TB_" + pkval + "_" + mapAttr.KeyOfEn + "Text").val($('#DDL_' + pkval + "_" + mapAttr.KeyOfEn).find("option:selected").text());
                        }
                    }
                }
            }


        }

        function ChangeKeyOfEnText(obj, KeyOfEn, pkval) {
            if ($("#TB_" + pkval + "_" + KeyOfEn + "Text").length == 1)
                $("#TB_" + pkval + "_" + KeyOfEn + "Text").val($(obj).find("option:selected").text());
        }

        function InitMapAttrOfCtrl(mapAttr, dtl, pkval) {

            var str = '';
            var defValue = ConvertDefVal(mapAttr, dtl);
            var isInOneRow = false; //是否占一整行
            var islabelIsInEle = false; //
            var eleHtml = '';

            //加入隐藏控件.
            if (mapAttr.UIVisible == 0) {

                html += "<input type='hidden' id='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' value='" + defValue + "' />";
            }

            //外部数据源类型.
            if (mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContralType == "1") {

                //枚举类型.
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = "";
                else
                    enableAttr = "disabled='disabled'";

                return "<select style='width:" + mapAttr.UIWidth * 2 + "px' class='form-control' id='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' name='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + " onchange='ChangeKeyOfEnText(this,\"" + mapAttr.KeyOfEn + "\",\"" + pkval + "\")'>" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
            }

            //外键类型.
            if (mapAttr.LGType == "2" && mapAttr.MyDataType == "1") {

                //枚举类型.
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = "";
                else
                    enableAttr = "disabled='disabled'";

                return "<select style='width:" + mapAttr.UIWidth * 2 + "px' class='form-control' id='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "'  name='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + ">" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
            }

            //外部数据类型.
            if (mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContral == 1) {

                //枚举类型.
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = "";
                else
                    enableAttr = "disabled='disabled'";

                return "<select style='width:" + mapAttr.UIWidth * 2 + "px' class='form-control' id='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' name='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + ">" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
            }

            //添加文本框 ，日期控件等
            //AppString
            if (mapAttr.MyDataType == "1" && mapAttr.UIContralType == 0) {  //不是外键

                //  alert(mapAttr.UIWidth);


                if (mapAttr.UIHeight <= 40) //普通的文本框.
                {
                    var enableAttr = '';
                    if (mapAttr.UIIsEnable == 0)
                        enableAttr = "disabled='disabled'";

                    return "<input  class='form-control' maxlength=" + mapAttr.MaxLen + "  name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' id='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' value='" + defValue + "' style='width:" + mapAttr.UIWidth + "px;height:34px;' type='text'  " + enableAttr + " />";
                }

                //普通的大块文本.
                return "<textarea class='form-control' maxlength=" + mapAttr.MaxLen + " style='height:" + mapAttr.UIHeight + "px;width:" + mapAttr.UIWidth + "px;' name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' id='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' type='text'  " + (mapAttr.UIIsEnable == 1 ? '' : ' disabled="disabled"') + " >" + defValue + "</textarea>"
            }

            //日期类型.
            if (mapAttr.MyDataType == 6) {
                var enableAttr = '';
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = 'onfocus="WdatePicker({dateFmt:' + "'yyyy-MM-dd'})" + '";';
                else
                    enableAttr = "disabled='disabled'";

                return "<input class='form-control' " + enableAttr + " value='" + defValue + "' style='width:105px;' name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' type='text' />";
            }

            //时期时间类型.
            if (mapAttr.MyDataType == 7) {

                var enableAttr = '';
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = 'onfocus="WdatePicker({dateFmt:' + "'yyyy-MM-dd HH:mm'})" + '";';
                else
                    enableAttr = "disabled='disabled'";

                return "<input class='form-control'  type='text' value='" + defValue + "' style='width:120px;' " + enableAttr + " name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "' />";
            }

            // boolen 类型.
            if (mapAttr.MyDataType == 4) {  // AppBoolean = 7

                if (mapAttr.UIIsEnable == 1)
                    enableAttr = "";
                else
                    enableAttr = "disabled='disabled'";

                //CHECKBOX 默认值
                var checkedStr = '';
                if (checkedStr != "true" && checkedStr != '1') {
                    checkedStr = ' checked="checked" ';
                }

                checkedStr = "";

                return "<label style='font-weight:50;' ><input  " + enableAttr + " value='1' " + (defValue == 1 ? "checked='checked'" : "") + " type='checkbox' id='CB_" + pkval + "_" + mapAttr.KeyOfEn + "'  name='CB_" + pkval + "_" + mapAttr.KeyOfEn + "' " + checkedStr + " />" + mapAttr.Name + "</label>";
            }

            //枚举类型.
            if (mapAttr.MyDataType == 2 && mapAttr.LGType == 1) { //AppInt Enum
                if (mapAttr.UIIsEnable == 1)
                    enableAttr = "";
                else
                    enableAttr = "disabled='disabled'";

                return "<select  style='width:" + mapAttr.UIWidth * 2 + "px' class='form-control'  name='DDL_" + pkval + "_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + ">" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
            }

            // AppDouble  AppFloat
            if (mapAttr.MyDataType == 5 || mapAttr.MyDataType == 3) {

                var enableAttr = '';
                if (mapAttr.UIIsEnable != 1)
                    enableAttr = "disabled='disabled'";

                // alert(mapAttr.KeyOfEn);
                return "<input class='form-control' style='text-align:right;width:80px;' value='" + defValue + "'  onkeyup=" + '"' + "if(isNaN(value)) execCommand('undo')" + '"' + " onafterpaste=" + '"' + "if(isNaN(value))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + "   type='text'" + enableAttr + " name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "'/>";
            }

            if ((mapAttr.MyDataType == 2)) { //AppInt
                var enableAttr = '';
                if (mapAttr.UIIsEnable == 0 || mapAttr.KeyOfEn == "NodeID") {
                    enableAttr = "disabled='disabled'";
                }
                return "<input class='form-control' style='text-align:right;width:80px;' value='" + defValue + "' onkeyup=" + '"' + "if(isNaN(value) || (value%1 !== 0))execCommand('undo')" + '"' + " onafterpaste=" + '"' + "if(isNaN(value) || (value%1 !== 0))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + "   type='text'" + enableAttr + " name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "'/>";
            }

            //AppMoney  AppRate
            if (mapAttr.MyDataType == 8) {
                var enableAttr = '';
                if (mapAttr.UIIsEnable == 1) {

                } else {
                    enableAttr = "disabled='disabled'";
                }
                return "<input class='form-control' style='text-align:right;width:80px;' value='" + defValue + "' onkeyup=" + '"' + "if(isNaN(value))execCommand('undo')" + '"' + " onafterpaste=" + '"' + "if(isNaN(value))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + "   type='text'" + enableAttr + " name='TB_" + pkval + "_" + mapAttr.KeyOfEn + "'/>";
            }

            alert(mapAttr.Name + "的类型没有判断.");
            return;
        }

        //填充默认数据
        function ConvertDefVal(attr, dtl) {

            //通过MAINTABLE返回的参数
            for (var ele in dtl) {
                if (attr.KeyOfEn == ele && dtl != '') {
                    result = dtl[ele];
                    break;
                }
            }

            if (result != undefined && typeof (result) == 'string') {
            }
            return result = unescape(result);
        }

        //初始化下拉列表框的OPERATION
        function InitDDLOperation(flowData, mapAttr, defVal) {

            var operations = '';

            var data = flowData[mapAttr.KeyOfEn];
            if (data == undefined)
                data = flowData[mapAttr.UIBindKey];
            if (data != undefined) {
                $.each(data, function (i, obj) {
                    operations += "<option " + (obj.No == defVal ? " selected='selected' " : "") + " value='" + obj.No + "'>" + obj.Name + "</option>";
                });
                return operations;
            }

            //外键类型.
            if (mapAttr.LGType == 2) {

                var data = frmData[mapAttr.KeyOfEn];
                if (data == undefined)
                    data = frmData[mapAttr.UIBindKey];

                if (data == undefined) {
                    alert('没有获得约定的数据源..' + mapAttr.KeyOfEn + " " + mapAttr.UIBindKey);
                    return;
                }

                //  alert(defVal);


                $.each(data, function (i, obj) {
                    operations += "<option " + (obj.No == defVal ? " selected='selected' " : "") + " value='" + obj.No + "'>" + obj.Name + "</option>";
                });
            }


            //枚举类型.
            if (mapAttr.LGType == 1) {

                var enums = frmData.Sys_Enum;
                enums = $.grep(enums, function (value) {
                    return value.EnumKey == mapAttr.UIBindKey;
                });

                $.each(enums, function (i, obj) {
                    operations += "<option " + (obj.IntKey == defVal ? " selected='selected' " : "") + " value='" + obj.IntKey + "'>" + obj.Lab + "</option>";
                });
            }


            //外部数据源类型 MyFlowGener.js.InitDDLOperation
            if (mapAttr.LGType == 0) {
                var fn;
                try {
                    if (mapAttr.UIBindKey) {
                        fn = cceval(mapAttr.UIBindKey);
                    }
                } catch (e) {
                }
                if (typeof fn == "function") {
                    $.each(fn.call(), function (i, obj) {
                        operations += "<option " + (obj.No == defVal ? " selected='selected' " : "") + " value='" + obj.No + "'>" + obj.Name + "</option>";
                    });
                } else if (typeof CommonHandler == "function") {
                    CommonHandler.call("", mapAttr.UIBindKey, function (data) {
                        GenerBindDDL("DDL_" + mapAttr.KeyOfEn, data, "No", "Name");
                    })
                } else {
                    alert('没有获得约定的数据源..' + mapAttr.KeyOfEn + " " + mapAttr.UIBindKey);
                    //alert('没有获得约定的数据源.');
                }

            }
            return operations;
        }

        //新建.
        var newRowCount = 0; //新增行
        function New() {
            newRowCount = newRowCount + 1;
            var ensName = GetQueryString("EnsName");
            var enName = ensName.substring(0, ensName.length - 1);
            var dtl = new Entity(enName);

            newRowIdx++;
            dtl.OID = newRowIdx;
            dtl.RefPK = GetQueryString("RefVal");

            var mapAttrs = frmData.Sys_MapAttr;

            var html = "";
            html += "<tr>";
            html += "<td class='Idx'><font color=red>" + (newRowIdx + 1) + "</font></td>";


            var hidden = "";

            for (var attrIdx = 0; attrIdx < mapAttrs.length; attrIdx++) {
                var mapAttr = mapAttrs[attrIdx];
                mapAttr = new Entity("BP.Sys.SysMapAttr", mapAttr);
                if (mapAttr.UIVisible == "0") {
                    html += "<input type='hidden' id='TB_" + newRowIdx + "_" + mapAttr.KeyOfEn + "' name='TB_" + newRowIdx + "_" + mapAttr.KeyOfEn + "' value='" + dtl[mapAttr.KeyOfEn] + "' />";
                    continue;
                }
                html += "<td>" + InitMapAttrOfCtrl(mapAttr, dtl, newRowIdx) + "</td>";
            }
            html += "<td >....</td>";
            html += "<td></td>";
            html += "</tr>";

            $("#Table1 tr:last").after(html);
            $("#Table1 tr:last").after(hidden);
        }

        //更新.
        function Save() {
            //点击保存后按钮不可编辑
            $("#Btn_Save").attr("disabled", true);
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
            handler.AddUrlData();  //增加参数属性.
            handler.AddFormData();
            handler.AddPara("NewRowCount", newRowCount);
            var data = handler.DoMethodReturnString("Dtl_Save");
            if (data.indexOf("err@") == 0) {
                alert(data);
                $("#Btn_Save").attr("disabled", false);
                return;
            }
            //   alert(data);
            Reload();
        }

        function Delete(pkval) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var ensName = GetQueryString("EnsName");
            var enName = ensName.substring(0, ensName.length - 1);

            //执行删除.
            var en = new Entity(enName);
            en.SetPKVal(pkval);
            en.Delete();

            Reload();
        }

        function CloseIt() {
            if (window.parent && window.parent.CloseBootstrapDialog) {
                window.parent.CloseBootstrapDialog("取消");
            } else {
                window.close();
            }
        }

        //导入
        function Import() {
            var title = mapData.Name + "导入数据";
            var W = document.body.clientWidth - 40;
            var H = document.body.clientHeight - 40;
            var url = "../../CCForm/DtlImpByExcel.htm?EnsName=" + GetQueryString("EnsName") + "&RefPKVal=" + GetQueryString("RefVal") + "&FK_MapData=" + GetQueryString("EnName");
            OpenBootStrapModal(url, "eudlgframe", title, W, H, "icon-edit", false, function () { }, null, function () {
                location = location;
            });
        }

        //导出
        function Export() {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
            handler.AddPara("EnsName", GetQueryString("EnsName"));
            handler.AddPara("RefKey", GetQueryString("RefKey"));
            handler.AddPara("RefVal", GetQueryString("RefVal"));
            //查询集合
            var data = handler.DoMethodReturnString("Dtl_Exp");
            var url = "";
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            data = basePath + "/" + data;
            window.open(data);
            return;

        }
    </script>
</head>
<body>
    <div class="container-full">
        <div class="attrnode-bar-header">
            <div class="pull-right" id="Btns">
                <!--  <input type='button' value='保存' id='Btn_Save' onclick='Save()' />-->
            </div>
        </div>
        <form id="divCCForm">
            <div id="mytable"> </div>
        </form>
        <div id="Msg"></div>
    </div>
</body>

</html>
